
require(['./config'],()=>{
    require(['template','header','footer'],(template)=>{
        class List{
            constructor(){
                this.getNavList()
                this. getgiftList()
            }
            // 渲染导航条
            getNavList(){
                $.get('http://www.xiongmaoyouxuan.com/api/tabs',resp=>{
                    if(resp.code===200){
                        let {list}=resp.data
                        list=list.slice(1,12)
                        $('#navList').html(template('navListTemplate',{list}))
                    }
                })
            }
            // 渲染列表数据
            getgiftList(){
                const id=location.search.slice(4)
                $.get(`http://www.xiongmaoyouxuan.com/api/tab/${id}`,resp=>{
                    if(resp.code===200){
                        let {list}=resp.data.items
                        list=list.filter(shop=>{
                            return shop.expireMsg
                        })
                        $('#giftList').html(template('giftListTemplate',{list}))  
                    }
                })
            }
        }
        new List()
    })
})